package it.koutifaris.travianmap.db.impl;

import it.koutifaris.travianmap.db.Tile;
import it.koutifaris.travianmap.model.MapSquare;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class TileImpl implements Iterable<MapSquare>, Tile {

	private Collection<MapSquare> squares;

	@Override
	public Iterator<MapSquare> iterator() {
		return squares.iterator();
	}

	public int getSize() {
		return (TILE_RADIUS + 1) * (TILE_RADIUS + 1);
	}

	protected Collection<MapSquare> getSquares() {
		if (squares == null)
			squares = new ArrayList<MapSquare>();
		return squares;
	}

	protected void addSquare(MapSquare square) {
		getSquares().add(square);
	}

}
